<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>V视频</title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
	<link rel="icon" type="image/png" href="imgs/logo.png">
	<link href="css/mui.css" rel="stylesheet"/>
	<style type="text/css">
		body { margin: 0; padding: 0; }
		#nodata { margin-top:50%; font-size:20px; text-align:center; float:none; }
		#more { margin: 0; padding:10px; width:100%; text-align:center; background: #FEFEFE; clear:both; }
	</style>
</head>
<body>
	<!-- 主体布局 -->
	<div id="list">
		<!--<span id="refresh"></span>-->
		<p id="nodata">正在获取...</p>
	</div>
	<!-- 主体布局 -->
</body>
</html>


<script src="js/mui.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/app.js"></script>
<script type="text/javascript">
	var cw = document.documentElement.clientWidth; //屏幕宽度
	var ch = document.documentElement.clientHeight; //屏幕高度
	var vWidth = cw / 2;
	var vHeight = Math.round(cw / 2 * 1.77777);
	//自动加载
	(function($, owner) {
//		setCover();
		getIndex();
	}(mui, window.app = {}));
	//获取数据
	function getIndex(){
		var formData = {};
		mui.ajax(domain+'/same/temp/index', {
			type:'post',
			data:formData,
			dataType:'json',
			timeout:timeout,
			headers:headers,
			success:function(res){
				//console.log(res);
				if (res.code!=0) {
					mui("#refresh")[0].innerHTML = '<p id="nodata">没有数据</p>';
					return
				}
				//console.log(showIndex(res.data));
				mui("#list")[0].innerHTML = showIndex(res.data);
			},
			error:function(){
				mui.toast('网络错误！');
			}
		});
	}
	//显示列表
	function showIndex(v){
		var h = '';
		for (var i=0;i< v.length;i++) {
			var id = v[i].id;
			var cover = v[i].cover, dn = v[i].dn;
			cover = cover ? dn+cover : 'imgs/tmp.png';
			h += '<div id="refresh">';
			h += '<div style="width:'+vWidth+'px;height:'+vHeight+'px;overflow:hidden;border:1px solid #CCC;float:left;" onclick="setToOne('+id+')">';
			h += '<img src="'+cover+'" style="width:'+vWidth+'px;height:'+vHeight+'px;position:relative;top:0;left:0;"/>';
			h += '</div>';
			h += '</div>';
		}
		h += '<p id="more">点击更多</p>';
		return h;
	}
	//更新封面
	function setCover(){
		var w = cw / 2, h = ch / 2;
		var formData = {
			w:w, h:h
		};
		mui.ajax(domain+'/same/temp/gif', {
			type:'post',
			data:formData,
			dataType:'json',
			timeout:timeout,
			headers:headers,
			success:function(res){
				console.log(res);
			},
			error:function(){
				mui.toast('网络错误！');
			}
		});
	}
	//到单个页面
	function setToOne(id){
		window.location.href = 'one.html?id='+id;
	}
</script>